/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package MyGame;

import DEMOS.LayerTwo;
import edu.chalmers.AV_2DPlatformerFramework.Model.*;
import edu.chalmers.AV_2DPlatformerFramework.Utility.Vector2D;
import java.awt.geom.Rectangle2D;

/**
 *
 * @author Richard
 */
public class Object_CanisterShot extends GameObject{

    public Object_CanisterShot(Vector2D finalVelocity) {
        super(null);
        super.setVelocity(finalVelocity);
        
        Vector2D[] vertices = { 
                                new Vector2D(3, 30), new Vector2D(3, 45), 
                                new Vector2D(30, 60), new Vector2D(95, 70),
                                new Vector2D(95, 5), new Vector2D(30, 15),
                              }; 
        try {
            this.setHitbox(new Hitbox(vertices));
        } catch (Hitbox.HitboxMalformedException ex) {
            System.out.println("Failed to create hitbox for: " + ex.getClass().getSimpleName());
        }
        
        String s = System.getProperty("file.separator");
        super.addTexture(new Texture("."+s+"src"+s+"main"+s+"java"+s+"Textures"+s+"cannon_ball.gif",
                                    new Rectangle2D.Double(0,0,120, 120)));
        super.setStrata(100);
    }

    @Override
    public void onCollision(GameObject otherObject) {
//        if (!(otherObject instanceof Object_Edmund))
//            return;
//        
//        this.setPosition(new Vector2D(-100, -100));
//        System.out.println("Edmund collided with a cannon ball!");
    }
    @Override
    public void setVelocity(Vector2D newVelocity){
        //do nothing
    }
    @Override
    public Vector2D getVelocity(){
        return super.getVelocity().copy(); //non-mutable
    }

    @Override
    public GameObject copy() {
        GameObject copy = new Object_CanisterShot(super.getVelocity());
        this.copyVariablesTo(copy);
        return copy;
    }
    
}
